package com.ty.day5;


import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/20 11:25
 */
public class Student {
    long id;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;//先判断是否是自己
        if (o == null || getClass() != o.getClass()) return false;//判断是否为空或者是否是同一个类型
        Student student = (Student) o;//强制转换
        return id == student.id;//返回值是否相等
    }

}
class Test{
    public static void main(String[] args) {
        Student student = new Student();
        student.id=123;
        Student student1 = new Student();
        student1.id=123;
        System.out.println(student.equals(student1));
        if (student.equals(student1)){
            System.out.println("是同一个学生");
        }else {
            System.out.println("不是一个");
        }
    }
}
